<template>
  <!-- <div class="part" v-if="isSelect1">
    <p>底图切换：</p>
    <div class="radio-buttons-container">
      <div class="radio-button">
        <input
          name="radio-group-operate"
          :id="`radio1`"
          class="radio-button__input"
          type="radio"
          value="0"
          v-model="selectedMap"
        />
        <label :for="`radio1`" class="radio-button__label">
          <span class="radio-button__custom"></span>
          行政区划
        </label>
      </div>
      <div class="radio-button">
        <input
          name="radio-group-operate"
          :id="`radio2`"
          class="radio-button__input"
          type="radio"
          value="1"
          v-model="selectedMap"
        />
        <label :for="`radio2`" class="radio-button__label">
          <span class="radio-button__custom"></span>
          地形图
        </label>
      </div>
    </div>
  </div> -->
  <div class="part" v-if="isSelect3">
    <p>图表切换：</p>
    <div class="radio-buttons-container">
      <div class="radio-button">
        <input
          name="radio-group-operate"
          :id="`chartRadio1`"
          class="radio-button__input"
          type="radio"
          value="0"
          v-model="selectedChart"
        />
        <label :for="`chartRadio1`" class="radio-button__label">
          <span class="radio-button__custom"></span>
          地图展示
        </label>
      </div>
      <div class="radio-button">
        <input
          name="radio-group-operate"
          :id="`chartRadio2`"
          class="radio-button__input"
          type="radio"
          value="1"
          v-model="selectedChart"
        />
        <label :for="`chartRadio2`" class="radio-button__label">
          <span class="radio-button__custom"></span>
          表格展示
        </label>
      </div>
    </div>
  </div>
  <div class="part" v-if="$route.name === 'FQYJ'">
    <p>信号切换：</p>
    <div class="signChange">
      <div class="radio-button">
        <input
          :id="`radio1`"
          class="radio-button__input"
          type="radio"
          value="0"
          v-model="selectSign"
        />
        <label :for="`radio1`" class="radio-button__label">
          <span class="radio-button__custom"></span>
          台风预警
        </label>
      </div>
      <div class="radio-button">
        <input
          :id="`radio2`"
          class="radio-button__input"
          type="radio"
          value="1"
          v-model="selectSign"
        />
        <label :for="`radio2`" class="radio-button__label">
          <span class="radio-button__custom"></span>
          暴雨预警
        </label>
      </div>
      <div class="radio-button">
        <input
          :id="`radio3`"
          class="radio-button__input"
          type="radio"
          value="2"
          v-model="selectSign"
        />
        <label :for="`radio3`" class="radio-button__label">
          <span class="radio-button__custom"></span>
          高温预警
        </label>
      </div>
      <div class="radio-button">
        <input
          :id="`radio4`"
          class="radio-button__input"
          type="radio"
          value="3"
          v-model="selectSign"
        />
        <label :for="`radio4`" class="radio-button__label">
          <span class="radio-button__custom"></span>
          雷雨大风预警
        </label>
      </div>
      <div class="radio-button">
        <input
          :id="`radio5`"
          class="radio-button__input"
          type="radio"
          value="4"
          v-model="selectSign"
        />
        <label :for="`radio5`" class="radio-button__label">
          <span class="radio-button__custom"></span>
          雷电预警
        </label>
      </div>
      <div class="radio-button">
        <input
          :id="`radio6`"
          class="radio-button__input"
          type="radio"
          value="5"
          v-model="selectSign"
        />
        <label :for="`radio6`" class="radio-button__label">
          <span class="radio-button__custom"></span>
          大风预警
        </label>
      </div>
      <div class="radio-button">
        <input
          :id="`radio7`"
          class="radio-button__input"
          type="radio"
          value="6"
          v-model="selectSign"
        />
        <label :for="`radio7`" class="radio-button__label">
          <span class="radio-button__custom"></span>
          雷暴预警
        </label>
      </div>
    </div>
  </div>
  <div class="part" v-if="isSelect2">
    <p>视图选择：</p>
    <div class="radio-buttons-container">
      <div class="radio-button">
        <input
          :id="`radio1`"
          class="radio-button__input"
          type="radio"
          value="1"
          v-model="selectView"
        />
        <label :for="`radio1`" class="radio-button__label">
          <span class="radio-button__custom"></span>
          {{ $route.name === "forecast" ? viewArr[1][0] : viewArr[0][0] }}
        </label>
      </div>
      <div class="radio-button">
        <input
          :id="`radio2`"
          class="radio-button__input"
          type="radio"
          value="2"
          v-model="selectView"
        />
        <label :for="`radio2`" class="radio-button__label">
          <span class="radio-button__custom"></span>
          {{ $route.name === "forecast" ? viewArr[1][1] : viewArr[0][1] }}
        </label>
      </div>
      <div class="radio-button">
        <input
          :id="`radio3`"
          class="radio-button__input"
          type="radio"
          value="3"
          v-model="selectView"
        />
        <label :for="`radio3`" class="radio-button__label">
          <span class="radio-button__custom"></span>
          {{ $route.name === "forecast" ? viewArr[1][2] : viewArr[0][2] }}
        </label>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    isSelect1: {
      type: Boolean,
      default: true,
    },
    isSelect2: {
      type: Boolean,
      default: false,
    },
    isSelect3: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      selectedMap: 0,
      selectView: 0,
      selectedChart: 0,
      selectSign: 0,
      viewArr: [
        ["QPE", "QPE(光流法)", "雷达视图"],
        ["QPF(DBZ)", "QPF(降水)", "QPF(光流法)"],
      ],
    };
  },
  watch: {
    selectSign() {
      this.$emit("changeSelectSign", this.selectSign);
    },
    selectView() {
      this.$emit("changeSelectView", this.selectView);
    },
  },
  created() {
    if (this.$route.name === "FQYJ") {
      this.$emit("changeSelectSign", this.selectSign);
    }
    if (this.$route.name === "recognition" || this.$route.name === "forecast") {
      this.$emit("changeSelectView", this.selectView);
    }
  },
};
</script>

<style>
.signChange {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  justify-items: start;
  gap: 10px;
  flex-wrap: wrap;
  padding: 0.2vw;
}
.part {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 0.5vw 0;
}
.radio-buttons-container {
  display: flex;
  align-items: center;
  gap: 42px;
  padding: 0 0.2vw;
  flex-wrap: wrap; /* 允许换行 */
}

.radio-button {
  display: inline-block;
  position: relative;
  cursor: pointer;
}

.radio-button__input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.radio-button__label {
  display: inline-block;
  padding-left: 30px;
  margin-top: 5px;
  position: relative;
  font-size: 16px;
  color: rgba(188, 205, 205, 1);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
}

.radio-button__custom {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid #555;
  transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
}

.radio-button__input:checked + .radio-button__label .radio-button__custom {
  transform: translateY(-50%) scale(0.9);
  border: 5px solid rgba(34, 181, 179, 1);
  color: rgba(34, 181, 179, 1);
}

.radio-button__input:checked + .radio-button__label {
  color: rgba(34, 181, 179, 1);
}

.radio-button__label:hover .radio-button__custom {
  transform: translateY(-50%) scale(1.2);
  border-color: rgba(34, 181, 179, 1);
  box-shadow: 0 0 10px rgb(26, 140, 138);
}
</style>
